package br.com.linhadotempo.struts2;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import br.com.linhadotempo.dao.FatoDAO;
import br.com.linhadotempo.util.Mensagens;
import br.com.linhadotempo.util.Sessao;
import br.com.linhadotempo.util.Util;
import br.com.taimlain.modelo.Usuario;

import com.opensymphony.xwork2.ActionSupport;

public class ImportTwitterAction extends ActionSupport {

	private Integer optionsRadios;

	@Action(value = "importTwitter", results = { @Result(name = SUCCESS, location = Util.LINHADOTEMPO_JSP) })
	public String execute() {
		try {
			Usuario usuario = (Usuario) Sessao.get(Util.USUARIO);
			
			usuario.getStatus().addAll(new FatoDAO().obterTwittsDe(usuario, optionsRadios));
			
			Sessao.put(Util.USUARIO, usuario);
		} catch (Exception e) {
			Mensagens.getInstance().setWarning("Ocorreu algum problema!");
			Mensagens.getInstance().tratarExceptions(e);
		}
		return SUCCESS;
	}

	public Integer getOptionsRadios() {
		return optionsRadios;
	}

	public void setOptionsRadios(Integer optionsRadios) {
		this.optionsRadios = optionsRadios;
	}

	private static final long serialVersionUID = 3685619468323931799L;
}
